<template>
    <div class="edu-page-warp">
        <ConditionCard
            shadow="never"
            body-style="padding: 24px 24px 6px 24px;"
            @search="onSubmit"
            @reset="reset('queryForm')"
        >
            <el-form ref="queryForm" :model="queryForm" label-position="right" label-width="80px">
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="6">
                        <el-form-item label="年级:" prop="grade">
                            <el-date-picker
                                v-model="queryForm.grade"
                                value-format="yyyy"
                                type="year"
                                placeholder="选择学年"
                                style="width: 100%"
                                @change="queryForm.projId == '1' ? queryCampusMajor() : ''"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="培养层次:" prop="trainingLevel">
                            <el-select
                                v-model="queryForm.trainingLevel"
                                style="width: 100%"
                                clearable
                            >
                                <el-option
                                    v-for="item in options.trainingLevel"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="审核状态:" prop="status">
                            <el-select v-model="queryForm.status" style="width: 100%" clearable>
                                <el-option
                                    v-for="item in options.status"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col v-if="queryForm.projId == '1'" :span="6">
                        <el-form-item label="类别:" prop="professionCateGory">
                            <el-select
                                v-model="queryForm.professionCateGory"
                                style="width: 100%;"
                                clearable
                            >
                                <el-option
                                    v-for="item in options.professionCateGory"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="学院:" prop="faculty">
                            <el-select
                                v-model="queryForm.faculty"
                                filterable
                                clearable
                                style="width: 100%"
                                @change="queryCampusMajor"
                            >
                                <el-option
                                    v-for="item in options.faculty"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <template v-if="queryForm.projId == '1'">
                        <el-col :span="6">
                            <el-form-item filterable label="专业:" prop="campusProfession">
                                <el-select
                                    v-model="queryForm.campusProfession"
                                    style="width: 100%"
                                    clearable
                                >
                                    <el-option
                                        v-for="item in options.campusProfessions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </template>
                </el-row>
            </el-form>
        </ConditionCard>
        <el-card shadow="never" body-style="padding: 24px;">
            <div class="edu-opertion-bar">
                <div class="float-left">
                    <el-input
                        v-model="queryForm.name"
                        placeholder="培养方案名称"
                        prefix-icon="el-icon-search"
                        @change="handSearchChang"
                    />
                </div>
                <div class="float-right">
                    <el-button @click="compared">比对</el-button>
                    <el-button @click="copy">复制</el-button>
                    <el-button @click="handleExportSchemes">
                        {{ $t('common.btn.export') }}
                    </el-button>
                    <!-- <el-button @click="advancedExport">
                        高级导出
                    </el-button> -->
                    <el-button v-if="showOperateButton" @click="handleDeleteSchemes">
                        {{ $t('common.btn.delete') }}
                    </el-button>
                    <el-button
                        v-if="showOperateButton"
                        type="primary"
                        @click="addCultrueScheme(true)"
                    >
                        {{ $t('common.btn.add') }}
                    </el-button>
                </div>
            </div>
            <el-table
                :data="tableData"
                stripe
                style="width: 100%"
                @selection-change="selectionChange"
                tooltip-effect="light"
            >
                <el-table-column type="expand">
                    <template slot-scope="props">
                        <div class="edu-auto-row">
                            <div class="edu-auto-col col">
                                <div class="edu-auto-label">方案名称：</div>
                                <div class="edu-auto-content">{{ props.row.name }}</div>
                            </div>
                            <div class="edu-auto-col col">
                                <div class="edu-auto-label">年级：</div>
                                <div class="edu-auto-content">{{ props.row.grade }}</div>
                            </div>
                            <div class="edu-auto-col col">
                                <div class="edu-auto-label">培养层次：</div>
                                <div class="edu-auto-content">
                                    {{ props.row.trainingLevelI18n }}
                                </div>
                            </div>
                            <div v-if="queryForm.projId == '1'" class="edu-auto-col col">
                                <div class="edu-auto-label">类别：</div>
                                <div class="edu-auto-content">
                                    {{ props.row.professionCateGory == '1' ? '专业大类' : '专业' }}
                                </div>
                            </div>
                            <div class="edu-auto-col col">
                                <div class="edu-auto-label">学院：</div>
                                <div class="edu-auto-content">{{ props.row.facultyI18n }}</div>
                            </div>
                            <div class="edu-auto-col col">
                                <div class="edu-auto-label">专业：</div>
                                <div class="edu-auto-content">
                                    <span>{{ props.row.campusProfessionName }}</span>
                                </div>
                            </div>
                            <div class="edu-auto-col col">
                                <div class="edu-auto-label">审核状态：</div>
                                <div class="edu-auto-content">
                                    <el-tag v-if="props.row.status == 3" type="success" size="mini">
                                        通过
                                    </el-tag>
                                    <el-tag v-if="props.row.status == 1" type="info" size="mini">
                                        草稿
                                    </el-tag>
                                    <el-tag v-if="props.row.status == 2" type="warning" size="mini">
                                        审核中
                                    </el-tag>
                                    <el-tag v-if="props.row.status == 5" type="danger" size="mini">
                                        变更中
                                    </el-tag>
                                </div>
                            </div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    type="selection"
                    disabled="true"
                    width="55"
                ></el-table-column>
                <!-- <el-table-column type="selection" width="55" disabled=""/> -->
                <el-table-column label="方案名称" prop="name" show-overflow-tooltip>
                    <template slot-scope="scope">
                        <span>
                            <el-button type="text" @click="preview(scope.row)">
                                {{ scope.row.name }}
                            </el-button>
                        </span>
                    </template>
                </el-table-column>
                <el-table-column label="年级" prop="grade" width="80" />
                <el-table-column label="培养层次" prop="trainingLevelI18n" width="80" />
                <el-table-column label="学院" prop="facultyI18n" />
                <el-table-column label="专业代码" prop="campusProfession" width="90" />
                <div v-if="queryForm.projId == '1'">
                    <el-table-column label="类别" width="100">
                        <template slot-scope="scope">
                            {{ scope.row.professionCateGory == '1' ? '专业大类' : '专业' }}
                        </template>
                    </el-table-column>
                </div>
                <template v-if="queryForm.projId == '1'">
                    <el-table-column
                        label="专业"
                        prop="campusProfessionName"
                        show-overflow-tooltip
                    />
                </template>
                <el-table-column label="下一级审核" prop="approvorName" width="105" show-overflow-tooltip/>
                <el-table-column label="审核状态" prop="status" width="80">
                    <template slot-scope="scope">
                        <el-tag v-if="scope.row.status == 3" type="success" size="mini">
                            通过
                        </el-tag>
                        <el-tag v-if="scope.row.status == 1" type="info" size="mini">草稿</el-tag>
                        <el-tag v-if="scope.row.status == 2" type="warning" size="mini">
                            审核中
                        </el-tag>
                        <el-tag v-if="scope.row.status == 5" type="danger" size="mini">
                            变更中
                        </el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="120">
                    <template slot-scope="scope">
                        <el-button
                            :disabled="role == 1 || role == 2 || scope.row.schemaIsopen == 1"
                            v-if="
                                scope.row.status == 1 ||
                                    (scope.row.status == 5 && scope.row.changeIn == 2)
                            "
                            type="text"
                            @click="handleEditItem(scope.row)"
                        >
                            编辑
                        </el-button>
                        <template v-if="showOperateButton">
                            <el-button
                                :disabled="role == 1 || role == 2 || scope.row.schemaIsopen == 1"
                                v-if="
                                    scope.row.status == 1 ||
                                        scope.row.status == 4 ||
                                        (scope.row.status == 5 && scope.row.changeIn == 2)
                                "
                                type="text"
                                @click="handleDelScheme(scope.row)"
                            >
                                删除
                            </el-button>
                        </template>
                        <template>
                            <el-button
                                :disabled="role == 1 || role == 2 || scope.row.schemaIsopen == 1"
                                v-if="scope.row.status == 3 && scope.row.changeIn == 0"
                                type="text"
                                @click="sendChangeRequest(scope.row)"
                            >
                                变更
                            </el-button>
                            <el-button
                                v-if="
                                    scope.row.status == 2 ||
                                        (scope.row.status == 3 && scope.row.changeIn != 0)
                                "
                                type="text"
                                @click="handleViewItem(scope.row)"
                            >
                                查看
                            </el-button>
                        </template>
                    </template>
                </el-table-column>
            </el-table>
            <div class="edu-pagination">
                <div class="float-right">
                    <el-pagination
                        :current-page="queryForm.pageNum_"
                        :page-sizes="[10, 20, 40, 100]"
                        :page-size="queryForm.pageSize_"
                        :total="queryForm.total"
                        layout="total, sizes, prev, pager, next, jumper"
                        style="float: right;margin:0;"
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                    />
                </div>
            </div>
        </el-card>
        <!-- 批量创建培养方案 -->
        <el-dialog
            :visible.sync="batchCreateSchemesVisible"
            title="批量创建培养方案"
            class="form-content"
            width="50%"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form
                ref="batchCultrueScheme"
                :model="batchCultrueScheme"
                :rules="batchCultrueSchemeRules"
                label-position="left"
                label-width="90px"
            >
                <el-row :gutter="20" style="height: 50px;">
                    <el-col :span="12">
                        <el-form-item label="年级:" prop="grade">
                            <el-date-picker
                                v-model="batchCultrueScheme.grade"
                                type="year"
                                value-format="yyyy"
                                placeholder="选择年级"
                                style="width: 100%;"
                                @change="batchFocusTplOpt"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="培养层次:" prop="trainingLevel">
                            <el-select
                                v-model="batchCultrueScheme.trainingLevel"
                                style="width: 100%;"
                                @change="batchFocusTplOpt"
                            >
                                <el-option
                                    v-for="item in options.trainingLevel"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="培养类别:" prop="trainingCategory">
                            <el-select
                                v-model="batchCultrueScheme.trainingCategory"
                                style="width: 100%"
                                @change="batchFocusTplOpt"
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in options.trainingCategory"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="学习形式:" prop="formLearning">
                            <el-select
                                v-model="batchCultrueScheme.formLearning"
                                style="width: 100%;"
                                placeholder="全部"
                                clearable
                                @change="batchFocusTplOpt"
                            >
                                <el-option
                                    v-for="item in options.formLearning"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item
                            :label="$t('culture.scheme.degreeType') + ':'"
                            prop="degreeType"
                        >
                            <el-select
                                v-model="batchCultrueScheme.degreeType"
                                style="width: 100%;"
                                placeholder="全部"
                                clearable
                                @change="
                                    batchFocusTplOpt()
                                    changeFaculty(batchCultrueScheme.faculty)
                                "
                            >
                                <el-option
                                    v-for="item in options.degreeType"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <hr class="hr" />
                <el-row :gutter="20" style="height: aut0;">
                    <el-col :span="12">
                        <el-form-item label="模板名称:" prop="templateId">
                            <el-select
                                ref="template"
                                v-model="batchCultrueScheme.templateId"
                                :loading="loadingTeml"
                                :disabled="!isShowTemplateSelect"
                                filterable
                                reserve-keyword
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.batchTemplateName"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="学院:" prop="faculty">
                            <el-select
                                ref="faculty"
                                v-model="batchCultrueScheme.faculty"
                                filterable
                                style="width: 100%;"
                                @change="changeFaculty"
                                multiple
                                collapse-tags
                                remote
                            >
                                <el-option
                                    v-for="item in options.faculty"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="专业:" prop="major">
                            <el-select
                                ref="major"
                                v-model="batchCultrueScheme.major"
                                filterable
                                multiple
                                collapse-tags
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.batchCultrueSchemeMajor"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="batchCultrueSchemeReset('batchCultrueScheme')">取 消</el-button>
                <el-button
                    :loading="addLoading"
                    type="primary"
                    @click="batchCultrueSchemeSubmit('batchCultrueScheme')"
                >
                    确 定
                </el-button>
            </span>
        </el-dialog>
        <!-- 本研新增 -->
        <el-dialog
            :visible.sync="showAddCultureSchemeDialog"
            title="创建培养方案"
            class="form-content"
            width="45%"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form
                ref="addCultureSchemeForm"
                :model="addCultureSchemeForm"
                :rules="addCultrueSchemeRules"
                label-position="right"
                label-width="96px"
            >
                <el-row :gutter="24" style="height: 27px;">
                    <el-col :span="24">
                        <el-checkbox
                            v-model="autoNameIsChecked"
                            style="float: right;"
                            label="自动命名"
                            name="type"
                        />
                    </el-col>
                </el-row>
                <!-- value="addCultureSchemeForm.name" -->
                <el-row style="height: 50px;">
                    <el-col :span="24">
                        <el-form-item label="方案名称:" prop="name">
                            <el-input
                                v-model="addCultureSchemeForm.name"
                                placeholder="请输入内容"
                                maxlength="50"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row style="height: 50px;">
                    <el-col :span="24">
                        <el-form-item label="英文名称:">
                            <el-input
                                v-model="addCultureSchemeForm.nameEn"
                                placeholder="请输入内容"
                                maxlength="70"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="20" style="height: 50px;">
                    <el-col :span="12">
                        <el-form-item label="年级:" prop="grade">
                            <el-date-picker
                                v-model="addCultureSchemeForm.grade"
                                type="year"
                                value-format="yyyy"
                                placeholder="请选择"
                                style="width: 100%;"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="培养层次:" prop="trainingLevel">
                            <el-select
                                v-model="addCultureSchemeForm.trainingLevel"
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.trainingLevel"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="queryForm.projId == 1" :gutter="20" style="height: 50px;">
                    <el-col :span="12">
                        <el-form-item label="类别:" prop="professionCateGory">
                            <el-select
                                v-model="addCultureSchemeForm.professionCateGory"
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.professionCateGory"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-else :gutter="20" style="height: 50px;">
                    <el-col :span="12">
                        <el-form-item label="类别:" prop="trainingCategory">
                            <el-select
                                v-model="addCultureSchemeForm.trainingCategory"
                                style="width: 100%"
                                clearable
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in options.trainingCategory"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="学习形式:" prop="formLearning">
                            <el-select
                                v-model="addCultureSchemeForm.formLearning"
                                style="width: 100%;"
                                placeholder="全部"
                                clearable
                            >
                                <el-option
                                    v-for="item in options.formLearning"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="queryForm.projId != 1">
                    <el-col>
                        <el-form-item
                            :label="$t('culture.scheme.degreeType') + ':'"
                            prop="degreeType"
                        >
                            <el-select
                                v-model="addCultureSchemeForm.degreeType"
                                style="width: 100%;"
                                placeholder="全部"
                                clearable
                            >
                                <el-option
                                    v-for="item in options.degreeType"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col>
                        <el-form-item label="模板:" prop="templateId">
                            <el-select
                                ref="template"
                                v-model="addCultureSchemeForm.templateId"
                                filterable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.templates"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="20" style="height: 50px;">
                    <el-col :span="12">
                        <el-form-item label="学院:" prop="faculty">
                            <el-select
                                ref="faculty"
                                v-model="addCultureSchemeForm.faculty"
                                filterable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.faculty"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col v-if="queryForm.projId == 1" :span="12">
                        <el-form-item label="专业:" prop="campusProfession">
                            <el-select
                                ref="campusProfession"
                                v-model="addCultureSchemeForm.campusProfession"
                                filterable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.campusProfessions"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row
                    v-if="
                        addCultureSchemeForm.projId == 1 &&
                            addCultureSchemeForm.professionCateGory &&
                            addCultureSchemeForm.professionCateGory == 2
                    "
                    :gutter="20"
                    style="height: 50px;"
                >
                    <!-- <el-col :span="12">
                        <el-form-item label="大类培养方案:" prop="trainingCategoryId">
                            <el-select
                                ref="faculty"
                                v-model="addCultureSchemeForm.trainingCategoryId"
                                filterable
                                style="width: 100%;"
                                @change="changeFaculty(addCultureSchemeForm.faculty)"
                            >
                                <el-option
                                    v-for="item in options.trainingCategoryId"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col> -->
                    <el-col :span="12">
                        <el-form-item label="大类培养方案:" prop="trainingCategoryId">
                            <el-select
                                v-model="addCultureSchemeForm.trainingCategoryId"
                                filterable
                                style="width: 100%;"
                            >
                                <el-option
                                    v-for="item in options.trainingCategoryId"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="showAddCultureSchemeDialog = false">
                    {{ $t('message.cancel') }}
                </el-button>
                <el-button type="primary" @click="addCultrueScheme()">
                    {{ $t('message.confirm') }}
                </el-button>
            </span>
        </el-dialog>

        <el-dialog
            :visible.sync="showSendChangeRequestDialog"
            title="变更"
            width="40%"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <span>是否同步到个人计划:</span>
            <el-radio v-model="isSynchronousPlan" label="0">不同步</el-radio>
            <el-radio v-model="isSynchronousPlan" label="1">同步</el-radio>
            <span slot="footer" class="dialog-footer">
                <el-button @click="showSendChangeRequestDialog = false">
                    {{ $t('message.cancel') }}
                </el-button>
                <el-button type="primary" @click="sendChangeRequest()">
                    {{ $t('message.confirm') }}
                </el-button>
            </span>
        </el-dialog>

        <el-dialog
            :visible.sync="showBatchCreateResultDialog"
            title="批量创建结果"
            width="40%"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <div>{{ result.msg }}</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="showBatchCreateResultDialog = false">
                    {{ $t('message.confirm') }}
                </el-button>
            </span>
        </el-dialog>
        <el-dialog
            title="删除培养方案结果提示"
            width="45%"
            :visible.sync="showResult"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <div style="font-size:18px">
                <i class="el-icon-warning"></i>
                <span>
                    本次共需删除{{ deleteResult.must }}个,
                    <b style="color:green">成功{{ deleteResult.success }}</b>
                    个,
                    <b style="color:red">失败{{ deleteResult.fail }}</b>
                    个.
                </span>
            </div>
            <div style="margin:10px 0">
                <div>
                    培养方案已被引用不能删除：
                    <b style="color:red">{{ deleteResult.isLead }}</b>
                    个，权限不足，无法删除通过，变更，删除的培养方案：
                    <b style="color:red">{{ deleteResult.isPass }}</b>
                    个，没有在培养方案开关设置时间内，无法删除的培养方案：
                    <b style="color:red">{{ deleteResult.noActive }}</b>
                    个
                </div>
            </div>
            <div v-if="deleteResult.fail && deleteResult.path">
                <el-button type="text" @click="download" size="mini">
                    点击下载excel查看详情
                </el-button>
            </div>
            <div style="text-align:right">
                <el-button @click="closeResultDialog" type="primary">确定</el-button>
            </div>
        </el-dialog>
        <el-dialog
            :visible.sync="showCopy"
            title="复制培养方案"
            width="35%"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form ref="grade" :model="copyForm" inline>
                <el-form-item
                    :rules="[{ required: true, message: '请选择年级'}]"
                    label="年级:"
                    prop="grade"
                >
                    <el-select v-model="copyForm.grade" placeholder="请选择年级" clearable>
                        <el-option
                            v-for="item in options.grade"
                            :key="item.value"
                            :label="item.label + '级'"
                            :value="item.value"
                        />
                    </el-select>
                </el-form-item>
                <el-form-item v-if="!!copyForm.grade">
                    <i class="el-icon-warning"></i>
                    <span>选择年级将会生成该年级新的方案</span>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancelCopy('grade')">取 消</el-button>
                <el-button type="primary" @click="confirmCopy('grade')">保存</el-button>
            </div>
        </el-dialog>
        <el-dialog
            :visible.sync="showAdvanceExport"
            title="高级导出"
            width="35%"
            height="50%"
        >
            <div style="width: 80%;margin: 0 auto">
                <el-form label-width="200" class="demo-dynamic">
                    <el-form-item label="学期" required>
                        <el-select placeholder="请选择学期" v-model="advanceInfo.semester" style="width: 75%">
                            <el-option
                                v-for="item in options.semester"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                            />
                        </el-select>
                    </el-form-item>
                </el-form>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button @click="closeDialog()">取 消</el-button>
                <el-button type="primary" @click="saveConfirm()">导出</el-button>
            </div>
        </el-dialog>
        <el-dialog
            :visible.sync="showCompared"
            title="课程比对"
            width="35%"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
            @close="cancelCompare"
        >
            <el-form ref="comparedForm" 
            :model="comparedForm"
            label-position="right"
            label-width="100px">
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="23">
                        <el-form-item
                            :rules="[{ required: true, message: '请选择年级'}]"
                            label="年级:"
                            prop="grade"
                        >
                            <el-date-picker
                                v-model="comparedForm.grade"
                                value-format="yyyy"
                                type="year"
                                placeholder="选择学年"
                                style="width: 100%"
                                @change="queryCampusMajor2()"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="23">
                        <el-form-item
                            :rules="[{ required: true, message: '请选择学院'}]"
                            label="学院:"
                            filterable
                            prop="faculty"
                        >
                            <el-select
                                v-model="comparedForm.faculty"
                                filterable
                                clearable
                                style="width: 100%"
                                @change="queryCampusMajor2"
                            >
                                <el-option
                                    v-for="item in options.facultys"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="23">
                        <el-form-item
                            :rules="[{ required: true, message: '请选择专业'}]"
                            label="专业/专业类:"
                            prop="major"
                        >
                            <el-select
                                v-model="comparedForm.major"
                                style="width: 100%"
                                @change="queryTerm"
                                clearable
                            >
                                <el-option
                                    v-for="item in comparedOptions.major"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="23">
                        <el-form-item
                            label="培养方案:"
                        >
                            <el-input
                                v-model="comparedForm.schemeName"
                                disabled
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="23">
                        <el-form-item
                            :rules="[{ required: true, message: '请选择学期'}]"
                            label="学期:"
                            prop="term"
                        >
                            <el-select 
                                v-model="comparedForm.term" 
                                placeholder="请选择学期" 
                                clearable
                                style="width: 100%"
                            >
                                <el-option
                                    v-for="item in comparedOptions.term"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancelCompare">取 消</el-button>
                <el-button type="primary" @click="confirmCompare">确定</el-button>
            </div>
        </el-dialog>
        <el-dialog
            :visible.sync="comparedDetails"
            title="比对结果"
            width="60%"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
            @close="closeCompare"
        >
            <el-table
                :data="compareData"
                style="width: 100%"
                tooltip-effect="light"
                border
                :span-method="objectSpanMethod"
            >
                <el-table-column label="课程名称" prop="coursesName" min-width="150" show-overflow-tooltip/>
                <el-table-column label="培养方案" prop="schemeName" min-width="250" show-overflow-tooltip/>
                <el-table-column label="课程类别" prop="label" width="120" show-overflow-tooltip/>
                <el-table-column label="课程区分" width="80">
                    <template slot-scope="scope">
                        <span v-if="scope.row.weeksType == '1'">实践周</span>
                        <span v-if="scope.row.weeksType == '0'">教学周</span>
                    </template>
                </el-table-column>
                <el-table-column label="考核方式" width="80">
                    <template slot-scope="scope">
                        <span v-if="scope.row.examMode == '1'">考试</span>
                        <span v-if="scope.row.examMode == '2'">考查</span>
                    </template>
                </el-table-column>
                <el-table-column label="是否必修" prop="compulsory" width="80">
                    <template slot-scope="scope">
                        <span v-if="scope.row.compulsory == '1'">否</span>
                        <span v-if="scope.row.compulsory == '0'">是</span>
                    </template>
                </el-table-column>   
            </el-table>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="closeCompare">关闭</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import bus from 'common/src/utils/bus'
// import * as API from "common/src/api/culture/cultruescheme";
import {
    cultureTemplateListNew,
    findProfessionByParam,
    findBelongBigProfessionByFaculty,
    findCultureSchemeList,
    changeCultureScheme,
    findCultureSchemeById,
    addCultureScheme,
    findTrainingCategoryScheme,
    checkCultureScheme,
    cultureTemplateList,
    batchDelCultureScheme,
    schemeListExport,
    batchAddCultureScheme,
    getResult,
    copyCultureScheme,
    getSchemeSchoolTermByIds,
    compareCultureScheme
} from 'common/src/api/culture/bachelor'
import { getPower, findAllDeptList } from 'common/src/api/culture/culturePlan'
import UTILS from 'common/src/utils/utils'
import { queryDic, findTrainingLevelByProjId, findDictByCondition, advanceExport } from 'common/src/api/dictionary'
import { getGraduateDegreePage } from 'common/src/api/resource/course'
import mixin from 'common/src/mixins/index';
export default {
    name: 'bcl-culture-scheme-manage',
    mixins: [mixin],
    data() {
        // const lengthRule = {
        //     min: 1,
        //     max: 256,
        //     message: "长度在 1 到 50 个字符",
        //     trigger: "blur"
        // };
        const lengthRule = {
            min: 1,
            max: 50,
            message: '长度在 1 到 50 个字符',
            trigger: 'blur'
        }
        //todo
        return {
            role: '',
            showBatchCreateResultDialog: false,
            showSendChangeRequestDialog: false,
            showAddCultureSchemeDialog: false,
            showAdvanceExport: false,
            addCultureSchemeForm: {
                name: '',
                nameEn: '',
                templateId: '',
                grade: '',
                trainingLevel: '',
                professionCateGory: '',
                faculty: '',
                major: '',
                campusProfession: '',
                formLearning: '',
                trainingCategory: [],
                condition: '',
                projId: '',
                degreeType: '',
                trainingCategoryId: ''
            },
            // addCultrueSchemeRules: {
            //     name: [
            //         {
            //             required: true,
            //             message: "请输入方案名称",
            //             trigger: "blur"
            //         },
            //         lengthRule
            //     ],
            //     nameEn: [
            //         {
            //             required: true,
            //             message: "请输入方案英文名称",
            //             trigger: "blur"
            //         },
            //         lengthRule
            //     ],
            //     templateId: [
            //         {
            //             required: true,
            //             message: "请选择培养模板",
            //             trigger: "change"
            //         }
            //     ],
            //     faculty: [
            //         { required: true, message: "请选择学院", trigger: "change" }
            //     ],
            //     major: [
            //         { required: true, message: "请选择专业", trigger: "blur" }
            //     ],
            //     campusProfession: [
            //         {
            //             required: true,
            //             message: "请选择校内专业",
            //             trigger: "change"
            //         }
            //     ],
            addCultrueSchemeRules: {
                name: [
                    {
                        required: true,
                        message: '请输入方案名称',
                        trigger: 'blur'
                    },
                    lengthRule
                ],
                nameEn: [
                    {
                        required: true,
                        message: '请输入方案英文名称',
                        trigger: 'blur'
                    },
                    lengthRule
                ],
                templateId: [
                    {
                        required: true,
                        message: '请选择培养模板',
                        trigger: 'change'
                    }
                ],
                faculty: [{ required: true, message: '请选择学院', trigger: 'change' }],
                major: [{ required: true, message: '请选择专业', trigger: 'blur' }],
                campusProfession: [
                    {
                        required: true,
                        message: '请选择校内专业',
                        trigger: 'change'
                    }
                ],
                professionCateGory: [{ required: true, message: '请选择类别', trigger: 'change' }],
                formLearning: [
                    {
                        required: false,
                        message: '请选择学习形式',
                        trigger: 'blur'
                    }
                ],
                trainingCategory: [
                    {
                        required: true,
                        message: '请选择培养类别',
                        trigger: 'blur'
                    }
                ],
                grade: [
                    {
                        required: true,
                        message: '请选择年级',
                        trigger: 'change'
                    }
                ],
                trainingLevel: [
                    {
                        required: true,
                        message: '请选择培养层次',
                        trigger: 'change'
                    }
                ],
                degreeType: [
                    {
                        required: false,
                        message: '请选择学位类型',
                        trigger: 'change'
                    }
                ]
            },
            loading: false,
            loadingTeml: false,
            cultrueScheme: {
                templateId: '',
                name: '',
                nameEn: '',
                grade: '',
                trainingLevel: '', // 培养层次
                trainingCategory: '', // 培养类别
                faculty: '', // 学院
                major: '', // 专业
                degreeCategory: '', // 学位类别
                degreeType: '', // 学位类型
                formLearning: '', // 学习形式
                spcialPlan: '', // 专项计划
                studentAbroad: '', // 留学生
                direction: '', // 方向
                lengthSchooling: '0', // 学制
                maxLengthSchooling: '0', // 最长在校时间
                remark: '' // 备注
            },
            batchCultrueScheme: {
                templateId: '',
                grade: '',
                trainingLevel: '', // 培养层次
                faculty: [], // 学院
                major: [], // 专业
                formLearning: '', // 学习形式
                degreeType: '', // 学位类型
                direction: '', // 方向
                trainingCategory: []
            },
            cultrueSchemeRules: {
                name: [
                    {
                        required: true,
                        message: '请输入方案名称',
                        trigger: 'blur'
                    },
                    {
                        min: 1,
                        max: 256,
                        message: '长度在 1 到 256 个字符',
                        trigger: 'blur'
                    }
                ],
                nameEn: [
                    {
                        min: 1,
                        max: 256,
                        message: '长度在 1 到 256 个字符',
                        trigger: 'blur'
                    }
                ],
                templateId: [
                    {
                        required: true,
                        message: '请选择培养模板',
                        trigger: 'blur'
                    }
                ],
                faculty: [{ required: true, message: '请选择学院', trigger: 'blur' }],
                major: [{ required: true, message: '请选择专业', trigger: 'blur' }],
                remark: [
                    {
                        min: 1,
                        max: 256,
                        message: '长度在 1 到 256 个字符',
                        trigger: 'blur'
                    }
                ]
            },
            batchCultrueSchemeRules: {
                grade: [{ required: true, message: '请选择学级', trigger: 'blur' }],
                trainingLevel: [
                    {
                        required: true,
                        message: '请选择培养层次',
                        trigger: 'change'
                    }
                ],
                trainingCategory: [
                    {
                        required: true,
                        message: '请选择培养类别',
                        trigger: 'change'
                    }
                ],
                formLearning: [
                    {
                        required: false,
                        message: '请选择学习形式',
                        trigger: 'change'
                    }
                ],
                templateId: [
                    {
                        required: true,
                        message: '请选择培养模板',
                        trigger: 'change'
                    }
                ]
            },
            // 筛选相关选项
            queryForm: {
                'x-token': '',
                grade: '', // 年级
                trainingLevel: '', // 培养层次
                faculty: '', // 学院
                major: '', // 专业
                degreeType: '', // 学位类型
                formLearning: '', // 学习形式
                spcialPlan: '', // 专项计划
                studentAbroad: '', // 留学生
                status: '', // 状态
                name: '', // 名称
                pageNum_: 1,
                pageSize_: 20,
                total: 0,
                projId: '1',
                professionCateGory: '',
                trainingCategory: []
            },
            advanceInfo: {
                semester: '',
                id: ''
            },
            // 下拉相关选项数据
            options: {
                grade: [],
                trainingLevel: [],
                faculty: [],
                facultys: [],
                major: [],
                batchCultrueSchemeMajor: [],
                degreeType: [],
                spcialPlan: [],
                formLearning: [],
                studentAbroad: [],
                semester: [],
                status: [
                    {
                        label: '通过',
                        value: 3
                    },
                    {
                        label: '草稿',
                        value: 1
                    },
                    {
                        label: '审核中',
                        value: 2
                    },
                    {
                        label: '变更中',
                        value: 5
                    }
                ],
                templateName: [],
                degreeType: [], // 学位类型
                degreeCategory: [], // 学位类别
                trainingCategory: [], // 培养类别,
                professionCateGory: [
                    { value: '1', label: '专业大类' },
                    { value: '2', label: '专业' }
                ],
                project: [],
                templates: [],
                campusProfessions: [],
                oldCampusProfessions:[],
                trainingCategoryId: [] //大类培养方案
            },
            tableData: [],
            autoNameIsChecked: false,
            showAlert: false, // 显示错误提示
            alertTitle: '',
            // 新增相关数据
            addFormVisible: false,
            examineVisible: false,
            schemeInfo: '',
            examineFileList: [],
            examineInfo: {
                type: 11,
                id: '',
                editExplain: '',
                evidenceList: []
            },
            addLoading: false,
            addFormRules: {},
            multipleSelection: [],
            batchCreateSchemesVisible: false,
            curItem: null,
            isSynchronousPlan: '1',
            result: {},
            showOperateButton: false,
            showResult: false,
            deleteResult: {
                must: '',
                success: '',
                fail: '',
                isLead: '',
                isPass: '',
                path: '',
                noActive: '',
            },
            showCopy: false,
            showCompared:false,
            comparedDetails:false,
            compareData:[],
            comparedForm: {
                grade: "",
                faculty: "", // 学院
                major: "", // 专业
                templateId: "",
                schemeName: "",
                term: "",
            },
            comparedOptions: {
                term: [],
                major: [],
            },
            copyForm: {
                grade: "",
                cultureSchemeIds: []
            },
            cultureSchemes:[],
        }
    },
    computed: {
        isShowTemplateSelect() {
            return (
                this.batchCultrueScheme.grade &&
                this.batchCultrueScheme.trainingLevel &&
                this.batchCultrueScheme.trainingCategory &&
                this.batchCultrueScheme.trainingCategory.length > 0
            )
        },
        faculty() {
            return this.addCultureSchemeForm.faculty
        },
        major() {
            return this.addCultureSchemeForm.major
        },
        campusProfession() {
            return this.addCultureSchemeForm.campusProfession
        },
        template() {
            return this.addCultureSchemeForm.templateId
        }
    },
    watch: {
        '$route' (to) {
            if(to.path=='/bclCultureSchemeManage'){
                this.onSubmit();
            }
        },
        showAddCultureSchemeDialog: function(_n, _o) {
            if (!_n) {
                this.resetAddForm()
                this.options.templates = []
                this.options.major = []
                this.options.campusProfessions = []
                this.autoNameIsChecked = false
            }
        },
        'addCultureSchemeForm.grade': function(_new, _old) {
            //清空大类培养方案列表
            this.options.trainingCategoryId = []

            let props = [
                'templateId', //* 模板
                'campusProfession', //* 校内专业
                'trainingCategoryId' //* 大类培养方案
            ]
            this.clearAddCultureSchemeForm(props)

            //* 获取模板
            this.addCultrueTemplates()

            //* 获取校内专业
            this.addCampusProfessions()

            //* 获取大类培养方案
            this.addTrainingCategoryId()
        },
        'addCultureSchemeForm.trainingLevel': function(_new, _old) {
            //清空大类培养方案列表
            this.options.trainingCategoryId = []
            //* 培养层次
            let props = [
                'templateId', //* 模板
                'campusProfession', //* 校内专业
                'trainingCategoryId' //* 大类培养方案
            ]
            this.clearAddCultureSchemeForm(props)

            //* 获取模板
            this.addCultrueTemplates()

            //* 获取校内专业
            this.addCampusProfessions()

            //* 获取大类培养方案
            this.addTrainingCategoryId()
        },
        'addCultureSchemeForm.professionCateGory': function(_new, _old) {
            //清空大类培养方案列表
            this.options.trainingCategoryId = []
            //* 类别
            let props = [
                'templateId', //* 模板
                'campusProfession', //* 校内专业
                'trainingCategoryId' //* 大类培养方案
            ]
            this.clearAddCultureSchemeForm(props)

            //* 获取模板
            this.addCultrueTemplates()

            //* 获取校内专业
            this.addCampusProfessions()

            //* 获取大类培养方案
            this.addTrainingCategoryId()
        },
        'addCultureSchemeForm.formLearning': function(_new, _old) {
            //* 学习形式
            let props = [
                'templateId' //* 模板
            ]
            this.clearAddCultureSchemeForm(props)

            //* 获取模板
            this.addCultrueTemplates()
        },
        'addCultureSchemeForm.trainingCategory': function(_new, _old) {
            //* 培养类别
            let props = [
                'templateId' //* 模板
            ]
            this.clearAddCultureSchemeForm(props)

            //* 获取模板
            this.addCultrueTemplates()
        },
        'addCultureSchemeForm.degreeType': function(_new, _old) {
            //* 学位类型
            if ('1' === this.addCultureSchemeForm.projId) {
                this.addCampusProfessions()
            }

            let props = [
                'templateId' //* 模板
            ]
            this.clearAddCultureSchemeForm(props)

            //* 获取模板
            this.addCultrueTemplates()
        },
        'addCultureSchemeForm.faculty': function(_new, _old) {
            //清空大类培养方案列表
            this.options.trainingCategoryId = []
            //* 学院
            let props = [
                'campusProfession', //* 校内专业,
                'major', //* 专业,
                'trainingCategoryId' //* 大类培养方案
            ]
            if (this.autoNameIsChecked) {
                this.addCultureSchemeForm.name = ''
            }
            this.clearAddCultureSchemeForm(props)

            //* 获取模板
            this.addCultrueTemplates()

            //* 获取校内专业或专业
            if ('1' === this.addCultureSchemeForm.projId) {
                this.addCampusProfessions()
            }
            //* 获取大类培养方案
            this.addTrainingCategoryId()
            this.autoName()
        },
        'addCultureSchemeForm.campusProfession': function(_new, _old) {
            //清空大类培养方案列表
            this.options.trainingCategoryId = []
            //* 校内专业
            let props = [
                'trainingCategoryId' //* 大类培养方案
            ]
            if (this.autoNameIsChecked) {
                this.addCultureSchemeForm.name = ''
            }
            this.clearAddCultureSchemeForm(props)

            //* 获取大类培养方案
            this.addTrainingCategoryId()
            this.autoName()
        },
        'addCultureSchemeForm.templateId': function(_new, _old) {
            //* 模板
            if (this.autoNameIsChecked) {
                this.addCultureSchemeForm.name = ''
            }
            this.autoName()
        },
        'addCultureSchemeForm.major': function(_new, _old) {
            //* 专业
            if (this.autoNameIsChecked) {
                this.addCultureSchemeForm.name = ''
            }
            this.autoName()
        },
        'options.trainingCategoryId': function(newValue) {
            if (newValue.length > 0)
                if (newValue.length === 0)
                    // this.addCultrueSchemeRules.trainingCategoryId = [
                    //     {
                    //         required: true,
                    //         message: "请选择大类培养方案",
                    //         trigger: "change"
                    //     }
                    // ];
                    delete this.addCultrueSchemeRules.trainingCategoryId
        }
    },
    created() {
        this.init()
        bus.$on('updateCurrentManageDeptId', currentManageDeptId => {
            this.queryForm.projId = currentManageDeptId
            this.handleChange()
            //清空筛选条件
            this.clearSearch()
        })
        this.initProjId()
        this.initTrainingLevelOptions()
        this.handleSearch()
        this.getRole()
    },
    methods: {
        // 获取当前登录角色power
        getRole() {
            getPower().then(res => {
                this.role = res.data.power
            })
        },
        //重新赋值
        // checkboxT(row, index) {
        //     if (row.schemaIsopen == 0 || this.role == 4) {
        //         return 1
        //     } else {
        //         return 0
        //     }
        // },
        initProjId() {
            let currentUser = this.global.currentUser
            this.queryForm.projId = currentUser.currentManageDptId
            // 校级管理员判断
            this.showOperateButton =
                currentUser.currentRole == 1 &&
                (currentUser.innerRoles.indexOf('1') != -1 ||
                    currentUser.innerRoles.indexOf('2') != -1)
        },
        initTrainingLevelOptions() {
            findTrainingLevelByProjId(this.queryForm.projId).then(res => {
                if (res.code === 200) {
                    this.queryForm.trainingLevel = ''
                    this.loadTrainingLevelOptions('trainingLevel', res.data)
                }
            })
        },
        preview(row) {
            this.$router.push({
                path: '/bclCultureTemplateView',
                query: {
                    projId: this.queryForm.projId,
                    id: row.id,
                    dataType: 2
                }
            })
        },
        //清空筛选条件
        clearSearch() {
            this.queryForm.grade = ''
            this.queryForm.trainingLevel = ''
            this.queryForm.faculty = ''
            this.queryForm.campusProfession = ''
            this.queryForm.major = ''
            this.queryForm.degreeType = ''
            this.queryForm.formLearning = ''
            this.queryForm.spcialPlan = ''
            this.queryForm.studentAbroad = ''
            this.queryForm.status = ''
            this.queryForm.name = ''
            this.queryForm.professionCateGory = ''
            this.queryForm.pageNum_ = 1
            this.queryForm.pageSize_ = 20
            this.queryForm.trainingCategory = []
            // 清空下拉
            this.options.campusProfessions = []
            this.options.major = []
        },
        addCultrueTemplates() {
            //* 获取模板
            let templatesParams = {}
            templatesParams.grade = this.addCultureSchemeForm.grade
            templatesParams.projId = this.addCultureSchemeForm.projId
            templatesParams.trainingLevel = this.addCultureSchemeForm.trainingLevel
            if (templatesParams.projId == '1') {
                templatesParams.professionCateGory = this.addCultureSchemeForm.professionCateGory
            } else {
                templatesParams.formLearning = this.addCultureSchemeForm.formLearning
                templatesParams.trainingCategory = this.addCultureSchemeForm.trainingCategory
                templatesParams.degreeType = this.addCultureSchemeForm.degreeType
            }
            this.queryCultureTemplates(templatesParams)
        },
        addCampusProfessions() {
            // 必须是本科生
            if ('1' !== this.addCultureSchemeForm.projId) {
                return
            }

            this.options.campusProfessions = []
            if (!(this.addCultureSchemeForm.grade && this.addCultureSchemeForm.faculty)) {
                // 年级选择提示
                this.$refs.addCultureSchemeForm.validateField('grade')
                return
            }

            let campusProfessionParams = {}
            campusProfessionParams.grade = this.addCultureSchemeForm.grade
            campusProfessionParams.trainingLevel = this.addCultureSchemeForm.trainingLevel
            campusProfessionParams.professionCateGory = this.addCultureSchemeForm.professionCateGory
            campusProfessionParams.category = this.addCultureSchemeForm.professionCateGory
            campusProfessionParams.faculty = this.addCultureSchemeForm.faculty

            this.queryCampusProfessions(campusProfessionParams)
        },
        addTrainingCategoryId() {
            //* 获取大类培养方案

            let params = {}
            params.grade = this.addCultureSchemeForm.grade
            //params.trainingLevel = this.addCultureSchemeForm.trainingLevel;
            params.professionCateGory = this.addCultureSchemeForm.professionCateGory
            params.faculty = this.addCultureSchemeForm.faculty
            params.campusProfession = this.addCultureSchemeForm.campusProfession

            // let campusProfessionItem = this.options.campusProfessions.find(
            //     item => {
            //         return (
            //             item.value == this.addCultureSchemeForm.campusProfession
            //         );
            //     }
            // );
            // if (campusProfessionItem) {
            //     params.campusProfessionName = campusProfessionItem.label;
            // }
            if (
                params.grade &&
                params.faculty &&
                params.campusProfession &&
                params.professionCateGory &&
                params.professionCateGory == 2
            ) {
                this.queryTrainingCategoryScheme(params)
            }
        },
        queryTrainingCategoryScheme(params) {
            const query = params || this.getCreateData()
            if (query.campusProfession) {
                findTrainingCategoryScheme(query).then(res => {
                    if (res.code == 200 && res.data) {
                        this.options.trainingCategoryId = res.data.map(e => {
                            return {
                                label: e.name,
                                value: e.id
                            }
                        })
                    }
                })
            }
        },
        queryOptions() {
            if (!this.isQuerytemplate()) return
            const query = this.getQueryTemplateParams()
            this.queryCultureTemplates(query)
            if (this.queryForm.projId == '1' && this.addCultureSchemeForm.faculty) {
                query.faculty = this.addCultureSchemeForm.faculty
                this.queryCampusProfessions(query)
            }
        },
        queryCampusProfessions(query) {
            // 查询校内专业（本科生）
            this.options.campusProfessions = []
            Vue.set(this.queryForm, 'campusProfession', '')
            findBelongBigProfessionByFaculty({
                category: query.professionCateGory,
                faculty: query.faculty,
                grade: Number(query.grade),
                projId: '1',
                pageNum_: 1,
                pageSize_: 100
            }).then(res => {
                if (res.code === 200) {
                    this.options.campusProfessions = res.data.list.map((item, index) => {
                        return {
                            label: item.professionName + '-' + item.professionCode,
                            value: item.professionCode
                        }
                    })
                    this.options.oldCampusProfessions = res.data.list.map((item, index) => {
                        return {
                            label: item.professionName,
                            value: item.professionCode
                        }
                    })
                }
            })
        },
        queryCampusProfessions2(query) {
            // 查询校内专业（本科生）
            this.comparedOptions.major = []
            Vue.set(this.comparedForm, 'major', '')
            findBelongBigProfessionByFaculty({
                category: '',
                faculty: query.faculty,
                grade: Number(query.grade),
                projId: '1',
                pageNum_: 1,
                pageSize_: 100
            }).then(res => {
                if (res.code === 200) {
                    this.comparedOptions.major = res.data.list.map((item, index) => {
                        return {
                            label: item.professionName + '-' + item.professionCode,
                            value: item.professionCode
                        }
                    })
                }
            })
        },
        queryTerm(){
            this.comparedForm.schemeName = []
            this.comparedOptions.term = []
            this.comparedForm.templateId = ""
            this.comparedForm.term = ""
            let data = {
                grade:this.comparedForm.grade,
                faculty:this.comparedForm.faculty,
                campusProfession:this.comparedForm.major,
                projId:'1',
                pageSize_:1,
                pageNum_:20
            }
            findCultureSchemeList(data)
                .then(res => {
                    if (res && res.data) {
                        if(res.data.list && res.data.list.length > 0){
                            this.comparedForm.schemeName = res.data.list[0].name
                            this.comparedForm.templateId = res.data.list[0].id
                            this.cultureSchemes.push(res.data.list[0].id)
                            getSchemeSchoolTermByIds(this.cultureSchemes).then(res => {
                                if (res.code == 200) {
                                    let schoolTerm = 0
                                    schoolTerm = res.data.schoolTerm 
                                    let list = [];
                                    let labelArr = ['一',  '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二', '十三', '十四', '十五', '十六', '十七', '十八', '十九', '二十'];
                                    for(let i = 0 ; i< schoolTerm; i++) {
                                        list.push({
                                            label: labelArr[i],
                                            value: i + 1,
                                            key: i + 1
                                        })
                                    }
                                    this.comparedOptions.term = list;
                                }
                            })
                        }
                    }
                })
        },
        cancelCompare(){
            this.showCompared = false
            this.$refs.comparedForm.resetFields();
            this.comparedForm.schemeName = ""
            this.comparedOptions.term = []
            this.comparedOptions.major = []
        },
        confirmCompare(){
            this.$refs['comparedForm'].validate(valid => {
                if (valid) {
                    let id = this.multipleSelection[0].id
                    compareCultureScheme(id,this.comparedForm.templateId,this.comparedForm.term).then(res => {
                        if (res.code === 200) {
                            this.showCompared = false;
                            this.comparedDetails = true;
                            this.compareData = this.comparedData(res.data) 
                        }
                    })
                } else return false
            })
        },
        closeCompare(){
            this.compareData = []   
            this.comparedDetails = false;
        },
        comparedData(data){
            let num = []
            data.forEach((d,index) =>{
                if(num.indexOf(d.courseCode) == -1){
                    console.log(num)
                    console.log(d.courseCode)
                    num = []
                    num = data.filter(f => f.courseCode == d.courseCode).map(r =>{
                        return r.courseCode
                    })
                    d.col = num.length
                }else{
                    d.col = 0
                }
            })
            console.log(data)
            return data
        },
        objectSpanMethod ({ row, column, rowIndex, columnIndex }) {
            if (columnIndex === 0) {
                console.log(row)
                if(row.col > 0){
                    return {
                        rowspan: row.col,
                        colspan: 1
                    };
                }else{
                    return {
                        rowspan: 0,
                        colspan: 0
                    };
                } 
            }
        },
        queryCultureTemplates(query) {
            cultureTemplateListNew(query).then(res => {
                if (res.code === 200) {
                    this.options.templates = res.data.map((item, index) => {
                        return {
                            label: item.name,
                            labelEn: item.nameEn,
                            value: item.id
                        }
                    })
                }
            })
        },
        isQuerytemplate() {
            const form = this.addCultureSchemeForm
            const flag = form.grade && form.trainingLevel
            if (form.projId == '1') return flag && form.professionCateGory
            else return flag && form.formLearning && form.trainingCategory
        },
        getQueryTemplateParams() {
            const data = {}
            data.grade = this.addCultureSchemeForm.grade
            data.projId = this.addCultureSchemeForm.projId
            data.trainingLevel = this.addCultureSchemeForm.trainingLevel
            if (data.projId == '1') {
                data.professionCateGory = this.addCultureSchemeForm.professionCateGory
            } else {
                data.formLearning = this.addCultureSchemeForm.formLearning
                data.trainingCategory = this.addCultureSchemeForm.trainingCategory
            }
            return data
        },
        addCultrueScheme(flag) {
            //to-delete
            if (flag) {
                this.addCultureSchemeForm.projId = this.queryForm.projId
                this.showAddCultureSchemeDialog = true
            } else this.createCultureScheme()
        },
        createCultureScheme() {
            //to-delete
            this.$refs['addCultureSchemeForm'].validate(valid => {
                if (valid) {
                    addCultureScheme(this.getCreateData()).then(res => {
                        if (res.code === 200) {
                            this.showAddCultureSchemeDialog = false
                            this.$message.success({
                                type: 'success',
                                message: '培养方案创建成功！'
                            })
                            this.handleSearch()
                        }
                    })
                } else return false
            })
        },
        getlabelFromOptions(option, value) {
            const item = this.options[option].find(item => {
                return item.value == value
            })
            if (item) return item
            else return ''
        },
        getCreateData() {
            this.addCultureSchemeForm.grade = this.addCultureSchemeForm.grade
            const campusProfessionItem = this.options.campusProfessions.find(item => {
                return item.value == this.addCultureSchemeForm.campusProfession
            })
            console.log(campusProfessionItem)
            if (campusProfessionItem) {
                this.addCultureSchemeForm.campusProfessionName = campusProfessionItem.label
                this.addCultureSchemeForm.campusProfession = campusProfessionItem.value
            }
            return this.addCultureSchemeForm
        },
        queryCampusMajor() {
            // 综合查询专业（本研不分）
            if (this.queryForm.projId == '1') {
                this.queryCampusProfessions(this.queryForm)
            }
        },
        queryCampusMajor2() {
            this.queryCampusProfessions2(this.comparedForm)
        },
        changeFaculty(faculty) {
            if (!faculty) {
                return
            }
            if (this.queryForm.projId == '1') {
                const query = this.getQueryTemplateParams()
                query.faculty = faculty
                this.queryCampusProfessions(query)
            } else {
                if (faculty.length > 0) {
                    let promiseArr = faculty.map(item =>
                        this.getGraduateDegreePage(item, this.batchCultrueScheme.degreeType)
                    )
                    Promise.all(promiseArr).then(res => {
                        this.options.batchCultrueSchemeMajor = res.reduce((prev, curr, index) => {
                            let {
                                code,
                                data: { list }
                            } = curr
                            if (code === 200) {
                                let majorList = list.map(item => ({
                                    value: item.code,
                                    label:
                                        'cn' !== this.$store.getters.language
                                            ? item.nameEn
                                            : item.name
                                }))
                                prev = [...prev, ...majorList]
                            }

                            return prev
                        }, [])
                        this.batchCultrueScheme.major = this.batchCultrueScheme.major.filter(
                            e =>
                                !!this.options.batchCultrueSchemeMajor.find(
                                    item => item.value === e
                                )
                        )
                    })
                    this.options.batchCultrueSchemeMajor = []
                }
            }
        },
        getGraduateDegreePage(college, degreeType) {
            const data = {
                college: college,
                page: false,
                isRecruit: 1,
                type: degreeType
            }
            return getGraduateDegreePage(data)
        },
        init() {
            this.queryForm['x-token'] =
                this.$store.state.session.sessionid || localStorage.getItem('sessionid') || ''
            for(var i = 1; i < 11; i++){
                this.options.semester.push({
                    key: i,
                    label: i,
                    value: i
                })
            }
            this.initOptions()
        },
        // 获取模板列表
        cultureTplOptions(str) {
            const that = this
            if (str !== '') {
                this.loadingTeml = true
                const query = {
                    condition: str
                }
                setTimeout(() => {
                    cultureTemplateList(query).then(res => {
                        this.loadingTeml = false
                        if (res && res.data) {
                            that.options.templateName = []
                            for (const index in res.data) {
                                const option = {
                                    label: res.data[index].name,
                                    value: res.data[index].id,
                                    item: res.data[index]
                                }
                                that.options.templateName.push(option)
                            }
                        }
                    })
                }, 200)
            } else {
                that.options.templateName = []
            }
        },
        changTplOpt(val) {
            const currentTplOpt = _.find(this.options.templateName, {
                value: val
            })
            this.cultrueScheme.trainingLevel = currentTplOpt.item.trainingLevel
            this.cultrueScheme.formLearning = currentTplOpt.item.formLearning
            this.cultrueScheme.grade = currentTplOpt.item.year
        },
        focusTplOpt() {
            const that = this
            this.loadingTeml = true
            that.options.templateName = []
            setTimeout(() => {
                cultureTemplateList().then(res => {
                    this.loadingTeml = false
                    if (res && res.data) {
                        that.options.templateName = []
                        for (const index in res.data) {
                            const option = {
                                label: res.data[index].name,
                                value: res.data[index].id,
                                item: res.data[index]
                            }
                            that.options.templateName.push(option)
                        }
                    }
                })
            }, 200)
        },
        batchFocusTplOpt() {
            if (!this.isShowTemplateSelect) {
                return
            }
            this.loadingTeml = true
            const params = {
                grade: this.batchCultrueScheme.grade, // 年级
                trainingLevel: this.batchCultrueScheme.trainingLevel, // 培养层次
                formLearning: this.batchCultrueScheme.formLearning, // 学习形式
                degreeType: this.batchCultrueScheme.degreeType // 学位类型
            }
            setTimeout(() => {
                cultureTemplateList(params).then(res => {
                    this.batchCultrueScheme.templateId = ''
                    this.loadingTeml = false
                    if (res && res.data) {
                        this.options.batchTemplateName = []
                        for (const index in res.data) {
                            const option = {
                                label: res.data[index].name,
                                value: res.data[index].id,
                                item: res.data[index]
                            }
                            this.options.batchTemplateName.push(option)
                        }
                    }
                })
            }, 200)
        },
        initOptions() {
            const data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: ['X_PYCC', 'X_YX', 'X_XXXS', 'X_ZXJH', 'X_PYLB', 'X_XWLB', 'X_XWLX', 'X_GLBM']
            }
            queryDic(data)
                .then(res => {
                    if (res.code === 200) {
                        // this.fillSelect(res.data);
                        UTILS.fillSelect(
                            {
                                faculty: 'X_YX',
                                degreeCategory: 'X_XWLB',
                                spcialPlan: 'X_ZXJH',
                                formLearning: 'X_XXXS',
                                degreeType: 'X_XWLX',
                                trainingCategory: 'X_PYLB',
                                project: 'X_GLBM'
                            },
                            res.data,
                            this.options
                        )
                    }
                })
                .catch(error => {
                    console.log(error)
                })
            // 绑定年级
            const now = new Date();
            const currentYear = now.getFullYear()+1;
            const minYear = currentYear - 7;
            for (let year = currentYear+4; year > minYear; year--) {
                const obj = { label: year, value: year };
                this.options.grade.push(obj);
            }
        },
        remoteCultureTemplates(str) {
            alert(str)
            this.cultureTplOptions(str)
        },
        handleChange() {
            // 动态培养层次数据
            findTrainingLevelByProjId(this.queryForm.projId).then(res => {
                if (res.code === 200) {
                    this.queryForm.trainingLevel = ''
                    this.loadTrainingLevelOptions('trainingLevel', res.data)
                }
            })
            this.handleSearch()
        },
        handleSearch() {
            findCultureSchemeList(this.queryForm)
                .then(res => {
                    if (res && res.data) {
                        this.tableData = res.data.list
                        this.queryForm.total = res.data.total_
                    }
                })
                .catch(function(error) {
                    this.$message({
                        type: 'error',
                        showClose: true,
                        message: '请求出现异常',
                        duration: 2000
                    })
                })
        },
        loadTrainingLevelOptions(optionKey, dataObj) {
            this.options[optionKey] = []
            _.each(dataObj, level => {
                this.options[optionKey].push({
                    label: 'en' === this.$store.getters.language ? level.nameEN : level.nameCN,
                    value: level.code
                })
            })
        },
        reset(ref) {
            this.clearSearch()
            this.handleChange()
        },
        onSubmit() {
            this.handleSearch()
        },
        handSearchChang() {
            this.handleSearch()
        },
        handleSizeChange(val) {
            this.queryForm.pageSize_ = val
            this.handleSearch()
        },
        handleCurrentChange(val) {
            this.queryForm.pageNum_ = val
            this.handleSearch()
        },
        handleDelScheme(obj) {
            const ids = []
            if (_.isArray(obj)) {
            } else {
                ids.push(obj.id)
            }
            this.handleDeleteSchemes(ids)
        },

        handleExamineScheme(item) {
            this.schemeInfo = item
            this.examineInfo.id = item.id
            this.examineVisible = true
        },
        handleAvatarPreview() {},
        handleAvatarRemove(file, fileList) {
            this.examineFileList = fileList
            this.examineInfo.evidenceList = _.map(fileList, 'name')
        },
        handleUploadSuccess(res, file, fileList) {
            this.examineFileList = fileList
            this.examineInfo.evidenceList = _.map(fileList, item => {
                return item.response.data[item.name].objectkey
            })
        },
        addButton() {
            this.addFormVisible = true
        },
        clearAddCultureSchemeForm(props) {
            _.each(props, prop => {
                this.addCultureSchemeForm[prop] = ''
            })
        },
        submitExamine() {
            if (this.examineFileList.length === 0 || this.examineInfo.editExplain === '') {
                this.$message({
                    message: '材料说明和证明材料不能为空！',
                    type: 'warning'
                })
                return
            }

            checkCultureScheme(this.examineInfo).then(res => {
                if (res && res.code !== 200) {
                    this.$message({
                        message: res.msg,
                        type: 'warning'
                    })
                    return
                }
                this.examineVisible = false
                this.examineInfo.editExplain = ''
                this.examineFileList = []
                this.$message({
                    message: '提交审核成功！',
                    type: 'success'
                })
                this.handleSearch()
            })
        },
        resetExamine() {
            this.examineInfo.evidenceList = []
            this.examineInfo.editExplain = ''
            this.examineFileList = []
            this.examineVisible = false
        },
        submitForm(formName) {
            this.$refs[formName].validate(valid => {
                if (valid) {
                    addCultureScheme(this.cultrueScheme).then(res => {
                        if (res && res.code === 200) {
                            this.addFormVisible = false
                            this.$notify.success({
                                title: '成功',
                                message: '培养方案创建成功！'
                            })
                            this.handleSearch()
                            return
                        }
                        if (res && res.code === 300) {
                            this.alertTitle = '培养方案名称不能重复！'
                            this.showAlert = true
                        }
                    })
                } else {
                    return false
                }
            })
        },
        resetForm(formName) {
            this.$refs[formName].resetFields()
            this.addFormVisible = false
        },
        copyScheme(item) {
            findCultureSchemeById({
                id: item.id
            }).then(res => {
                this.cultrueScheme = res.data
                this.addFormVisible = true
            })
        },
        closeAlert() {
            this.showAlert = false
        },
        handleEditItem(item) {
            if (!item.id && !item.projId) return
            this.$router.push({
                path: '/bclCultureSchemeDetail',
                query: {
                    id: item.id,
                    projId: item.projId,
                    templateId: item.templateId,
                    status: item.status
                }
            })
        },
        sendChangeRequest(item) {
            if (item) {
                this.curItem = item
                this.showSendChangeRequestDialog = true
                return
            } else {
                if (!this.curItem) return
                let params = {
                    id: this.curItem.id,
                    isSynchronousPlan: this.isSynchronousPlan
                }
                changeCultureScheme(params).then(res => {
                    if (res.code == 200) {
                        this.onSubmit()
                        this.showSendChangeRequestDialog = false
                        this.$router.push({
                            path: '/bclCultureSchemeDetail',
                            query: {
                                id: res.data.id,
                                projId: this.curItem.projId,
                                status: 5
                            }
                        })
                    }
                })
            }
        },
        handleViewItem(item) {
            this.$router.push({
                path: '/bclCultureSchemeDetail',
                query: {
                    id: item.id,
                    projId: item.projId
                }
            })
        },
        selectionChange(selection) {
            const self = this
            self.multipleSelection = selection
        },
        handleExportSchemes() {
            const ids = _.map(this.multipleSelection, 'id')
            if (ids.length === 0) {
                this.$notify.warning({
                    title: '提示',
                    message: '您还没有选择任何方案！'
                })
                return
            }
            const str = ids.join(',')
            const params = {
                cultureIds: str,
                'x-token':
                    this.$store.state.session.sessionid || localStorage.getItem('sessionid') || ''
            }
            schemeListExport(params)
        },
        handleDeleteSchemes(ids) {
            if (!ids.length) {
                ids = _.map(this.multipleSelection, 'id')
            }
            if (ids.length === 0) {
                this.$notify.warning({
                    title: '提示',
                    message: '您还没有选择任何方案！'
                })
                return
            }
            //const idx = this.multipleSelection.findIndex(
            //  e => e.status * 1 == 2
            //  );
            // if (idx > -1) {
            //  this.$notify.warning({
            //  title: "提示",
            //  message: "所选列表方案状态中存在审核中状态,暂不支持删除!"
            // });
            //  return;
            // }
            this.$confirm('确认删除所选列表方案,是否继续?', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                closeOnClickModal: false,
                closeOnPressEscape: false,
                type: 'warning'
            }).then(() => {
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(255, 255, 255, .48)'
                })
                let sleep = ms => {
                    return new Promise(resolve => setTimeout(resolve, ms))
                }
                let loaded = false
                let key = ''
                //重复发送请求，直到自动关联完成
                let delayRequest = async () => {
                    if (loaded) {
                        await sleep(5000)
                    } else {
                        loaded = true
                    }
                    getResult(key)
                        .then(res => {
                            if (res.code == 200 && res.data.status) {
                                this.showResult = true
                                this.deleteResult.must = res.data.must
                                this.deleteResult.success = res.data.success
                                this.deleteResult.fail = res.data.fail
                                this.deleteResult.isLead = res.data.isLead
                                this.deleteResult.isPass = res.data.isPass
                                this.deleteResult.path = res.data.path
                                this.deleteResult.noActive = res.data.noActive
                                loading.close()
                                this.handleSearch()
                            } else {
                                delayRequest()
                            }
                        })
                        .catch(ex => {
                            delayRequest()
                        })
                }

                batchDelCultureScheme(ids).then(res => {
                    if (res.code == 200) {
                        key = res.data.key
                        delayRequest()
                    }
                })
            })
        },
        download() {
            window.open(
                '/api/cultureservice/bclCultureScheme/export?path=' + this.deleteResult.path
            )
        },
        closeResultDialog() {
            this.showResult = false
        },

        batchCultrueSchemeReset(formName) {
            this.$refs[formName].resetFields()
            this.batchCreateSchemesVisible = false
        },
        batchCultrueSchemeSubmit(formName) {
            this.$refs[formName].validate(valid => {
                if (valid) {
                    this.batchCultrueScheme.projId = this.queryForm.projId
                    let batchCultrueSchemeCopy = JSON.parse(JSON.stringify(this.batchCultrueScheme))
                    if (batchCultrueSchemeCopy.faculty.length === 0) {
                        batchCultrueSchemeCopy.faculty = this.options.faculty.map(
                            item => item.value
                        )
                    } else {
                        if (batchCultrueSchemeCopy.major.length === 0) {
                            batchCultrueSchemeCopy.major = this.options.batchCultrueSchemeMajor.map(
                                item => item.value
                            )
                        }
                    }
                    batchCultrueSchemeCopy.faculty = batchCultrueSchemeCopy.faculty.join(',')
                    batchCultrueSchemeCopy.major = batchCultrueSchemeCopy.major.join(',')
                    batchAddCultureScheme(batchCultrueSchemeCopy).then(res => {
                        if (res && res.code === 200) {
                            this.batchCreateSchemesVisible = false
                            this.showBatchCreateResultDialog = true
                            this.result.msg =
                                '由于培养方案批量创建数据量大，正在处理中，可稍等10分钟后刷新页面或前往公共导出页面查看批量创建培方案情况表格。'
                            this.handleSearch()
                            this.$refs[formName].resetFields()
                        }
                    })
                } else {
                    return false
                }
            })
        },
        resetAddForm() {
            this.$refs.addCultureSchemeForm.resetFields()
        },
        autoName() {
            if (!this.autoNameIsChecked) return
            const form = this.addCultureSchemeForm
            if (form.grade && form.faculty && (form.major || form.campusProfession)) {
                const faculty = this.getlabelFromOptions('faculty', form.faculty)
                const major =
                    this.queryForm.projId == '1'
                        ? this.getlabelFromOptions('oldCampusProfessions', form.campusProfession)
                        : this.getlabelFromOptions('major', form.major)
                const template = this.getlabelFromOptions('templates', form.templateId)
                // form.name = `${faculty.label}/${major.label}-${template.label}`
                form.name = `${form.grade}级${faculty.label}${major.label}(${major.value})`
                let getFacultyPromise = findDictByCondition({
                    type: 'X_YX',
                    code: form.faculty
                })
                let getMajorPromise = findDictByCondition({
                    type: 'G_ZY',
                    code: form.major || form.campusProfession
                })
                Promise.all([getFacultyPromise, getMajorPromise]).then(function(data) {
                    let [faculty, major] = data
                    let facultyEn = ''
                    let majorEn = ''
                    if (faculty.code === 200) {
                        facultyEn = faculty.data[0] ? faculty.data[0].nameEN : facultyEn
                    }
                    if (major.code === 200) {
                        majorEn = major.data[0] ? major.data[0].nameEN : majorEn
                    }

                    form.nameEn =
                        facultyEn || majorEn || template.labelEn
                            ? `${form.grade}${facultyEn}${majorEn}(${major.value}) ? template.labelEn : ''}`
                            : ''
                })
            }
        },
        compared() {
            this.cultureSchemes = [];
            if (this.multipleSelection.length === 0) {
                this.$message({
                    type: "warning",
                    message: "请选择要比对的培养方案"
                });
                return;
            }
            if (this.multipleSelection.length > 1) {
                this.$message({
                    type: "warning",
                    message: "只能选择一条培养方案做比对"
                });
                return;
            }
            this.cultureSchemes.push(this.multipleSelection[0].id)
            findAllDeptList().then(res => {
                if (res.code == 200) {
                    this.options.facultys = res.data.map(item => {
                        return {
                            label: item.deptName,
                            value: item.deptCode
                        }
                    })
                }
            });
            this.showCompared = true;
        },
        copy() {
            if (this.multipleSelection.length === 0) {
                this.$message({
                    type: "info",
                    message: "请选择要复制的培养方案"
                });
                return;
            }
            this.showCopy = true;
        },
        confirmCopy(formName) {
            this.$refs[formName].validate(valid => {
                if (valid) {
                    this.copyForm.cultureSchemeIds = _.map(this.multipleSelection, "id");
                    copyCultureScheme(this.copyForm).then(res => {
                        if (res && res.code === 200) {
                            this.showCopy = false;
                            let message =
                                "由于培养方案批量复制每条数据结果差异，可前往公共导出页面查看批量复制培方案情况表格详情。";
                            this.$alert(message, "批量复制结果").then(res => {
                                this.onSubmit();
                                this.multipleSelection.length = 0;
                                this.$refs[formName].resetFields();
                            });
                        }
                    });
                }
            });
        },
        cancelCopy(formName) {
            this.showCopy = false;
            this.$refs[formName].resetFields();
        },
        /**
         * 高级导出
         */
        advancedExport() {
            const ids = _.map(this.multipleSelection, 'id')
            if (ids.length === 0) {
                this.$notify.warning({
                    title: '提示',
                    message: '您还没有选择任何方案！'
                })
                return
            } else if (ids.length > 1) {
                this.$notify.warning({
                    title: '提示',
                    message: '只能选择一条数据'
                })
                return
            }
            this.advanceInfo.id = ids[0];
            this.showAdvanceExport = true;
        },
        saveConfirm() {
            advanceExport(this.advanceInfo.id, this.advanceInfo.semester);
            this.showAdvanceExport = false;
        },
        closeDialog() {
            this.showAdvanceExport = false;
        }
    }
}
</script>
<style lang="sass" scoped>

</style>
